<template>
	<view class="content">
		<pluge-lection @getSort="getSort"></pluge-lection>
		<goods-list @goGoodsDetails="goGoodsDetails" :getDataList="getDataList"></goods-list>
		<iconStatus v-if="!getDataList.length" :imgUrl="'/pageIndex/static/icon23.png'" :statusInfo="'暂无数据'"></iconStatus>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import plugeLection from '@/components/goodsList/plugeLection.vue';
	import goodsList from '@/components/goodsList/goodsList.vue';
	import iconStatus from '@/components/noRecordIcon/iconStatus.vue';
	export default {
		data(){
			return {
				getDataList:[],//数据列表
				page:1,//页码
				limit:10,//条数
				type:"",//类型
				sale:"",//销量
				price:"",//价格
				mer_id:"",//门店ID
			}
		},
		onLoad(options) {
			uni.showLoading({title:"加载中"});
			uni.setNavigationBarTitle({
			    title: options.dynTitle
			});
			this.type = options.type;
			this.mer_id = options.merId||'';
			this.getProductLst();
		},
		methods:{
			getSort(e){
				uni.showLoading({title:"加载中"});
				this.page=1;
				this.getDataList = [];
				if(e.type=='sales'){
					this.sale = e.sort;this.price = "";
				}else if(e.type=='price'){
					this.price = e.sort;this.sale = "";
				}else{
					this.price = "";this.sale = "";
				}
				this.getProductLst();
			},
			getProductLst(){
				const { mer_id, sale, price, type, page, limit } = this;
				this.$u.api.productLstApi({ mer_id, sale, price, type, page, limit }).then(res=>{
					if(res.code==1){
						if(this.page==1){
							console.log('产品列表：',res);
							this.getDataList = res.data;
						}else{
							if(res.data.length>0){
								this.getDataList = this.storeList.concat(res.data);
							}else{
								this.$refs.uToast.show({title: '没有更多了',position:'center'});
							}
						}
					}
				});
			},
			goGoodsDetails(goodsId){ //go商品详情
				this.$gourl(`../../pageCart/goodsInfo/goodsInfo?goodsId=${goodsId}&merId=${this.mer_id}`);
			}
		},
		onReachBottom(){
			this.page++;
			uni.showLoading({title:"加载中"});
			this.getProductLst();
		},
		components:{
			plugeLection,
			goodsList,
			iconStatus
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		
	}
</style>